#!/bin/sh

. /etc/profile

start()
{
    printf "Starting node-red: "

    start-stop-daemon -S -q -b -m -p /var/run/node-red.pid \
		      --exec node-red

    [ $? = 0 ] && echo "OK" || echo "FAIL"
}

stop()
{
    printf "Stopping node-red: "
    start-stop-daemon -K -q -p /var/run/node-red.pid
    [ $? = 0 ] && echo "OK" || echo "FAIL"
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart)
	stop
	start
	;;
    *)
	;;
esac
